package com.black.common;

import lombok.Data;

/**
 * @Author: Young
 * @CreateTime: 2025-08-06
 * @Description: 公共返回对象
 * @Version: 1.0
 */
@Data
public class R {

    private Integer code;
    private String message;
    private Object data;

    public static R ok() {
        R r = new R();
        r.setCode(200);
        r.setMessage("success");
        return r;
    }

    public static R ok(Object data) {
        R r = new R();
        r.setCode(200);
        r.setMessage("success");
        r.setData(data);
        return r;
    }

    public static R ok(String message, Object data) {
        R r = new R();
        r.setCode(200);
        r.setMessage(message);
        r.setData(data);
        return r;
    }

    public static R ok(Integer code, String message, Object data) {
        R r = new R();
        r.setCode(code);
        r.setMessage(message);
        r.setData(data);
        return r;
    }

    public static R error() {
        R r = new R();
        r.setCode(500);
        r.setMessage("error");
        return r;
    }

    public static R error(String message) {
        R r = new R();
        r.setCode(500);
        r.setMessage(message);
        return r;
    }

    public static R error(Integer code, String message) {
        R r = new R();
        r.setCode(code);
        r.setMessage(message);
        return r;
    }

    public static R error(Integer code, String message, Object data) {
        R r = new R();
        r.setCode(code);
        r.setMessage(message);
        r.setData(data);
        return r;
    }
}
